<?php
/********************************************************************
**************************************************************************

WPBoxes WordPress Theme, Copyright 2012 ItsAbhik.com
WPBoxes is distributed under the terms of the GNU GPLv3 License

**************************************************************************
***********************************************************************/
?>

<?php get_header(); ?>
<div id="content">
	<?php if (wpboxes_options('wpboxes_tw') == 'show') { ?>
		<div id="top-widget">
			<?php if ( dynamic_sidebar('top-widget') ) : else : ?>
			<?php endif; ?>
			<div class="clear"></div>
		</div>
	<?php } ?>	

	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
	
		<?php if (wpboxes_options('wpboxes_sab') == 'show' && wpboxes_options('wpboxes_abp') == 'above') { echo ''.wpboxes_author_meta().'<div class="clear"></div>'; } ?>
		
		<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
			<div class="headline-area">
			<img src="<?php echo wpboxes_single_tn();?>" class="" alt="" width="100" height="100" />
			<div class="post-title"><h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1></div>
			
			<?php if (wpboxes_options('wpboxes_sbl') == 'show') { ?>
			<div class="postmeta">Posted By <span><?php the_author(); ?></span>&nbsp;&nbsp;&nbsp;on <span><?php the_date(); ?></span>&nbsp;&nbsp;&nbsp;at <span><?php the_time('g:i a'); ?></span></div>
			<?php } ?>
			
			<?php if (wpboxes_options('wpboxes_sss') == 'show') { wpboxes_sssb(); } ?>
			<div class="clear"></div>
			</div>
			<?php $attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) );
					foreach ( $attachments as $k => $attachment ) {
						if ( $attachment->ID == $post->ID )
							break;
						}
			$k++;
			// If there is more than 1 attachment in a gallery
			if ( count( $attachments ) > 1 ) {
				if ( isset( $attachments[ $k ] ) )
					// get the URL of the next image attachment
					$next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
				else
					// or get the URL of the first image attachment
					$next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
			} else {
				// or, if there's only 1 image, get the URL of the image
				$next_attachment_url = wp_get_attachment_url();
			} ?>

								<div class="gallerysingleimage">
									<?php echo wp_get_attachment_image( $attachment->ID, array(550,450) ); ?>
								</div>
				
				<?php the_content(); ?>	

				<?php if ( count( $attachments ) > 1 ) { ?>
					<div class="navigation">
						<div class="next-posts"><?php next_image_link(' ', 'Next Image &rarr;'); ?></div>
						<div class="prev-posts"><?php previous_image_link(' ', '&larr; Previous Image'); ?></div>
					</div>
				<?php } ?>

				<?php $args = array('before' => '<div class="clear"></div><div class="postpagination"> Pages:', 'after' => '</div><div class="clear"></div>', 'link_before' => '',
							'link_after'       => '', 'next_or_number' => 'number', 'nextpagelink' =>'Next Page', 'previouspagelink' =>'Previous Page', 'pagelink' => '%', 'echo' => 1 ); 
						wp_link_pages( $args ); ?>

		</div>
			<div class="clear"></div>
		
		<?php if (wpboxes_options('wpboxes_sab') == 'show' && wpboxes_options('wpboxes_abp') == 'below') { echo ''.wpboxes_author_meta().'<div class="clear"></div>'; } ?>
				
				<div class="clear"></div>
						
								<?php // if (wpboxes_options('simplicity_after_post_widget') == 'show') { ?>
									<div id="afterpost-widget">
										<?php // if ( dynamic_sidebar('after_post_widget') ) : else : ?>
										<?php //endif; ?>
								<div class="clear"></div>
								</div>
								<?php // } ?>
						
						
				
				<?php comments_template(); ?>


	<?php endwhile; ?>
				
				<div class="clear"></div>

	<div class="navigation">
		<div class="next-posts"><?php next_post_link('%link &rarr;'); ?></div>
		<div class="prev-posts"><?php previous_post_link('&larr; %link'); ?></div>
	</div>


<?php else : ?>

	<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
		<h1>Not Found</h1>
	</div>

<?php endif; ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>